package pers.vic.util.excel.other;

import java.util.ArrayList;
import java.util.List;

import org.apache.poi.ss.usermodel.DataValidation;

/**
 * 描述: excel导出模板和导入模板表头定义 <br>
 */
public class ExcelTplField {
    /**
     * 表头中文名
     */
    private String headName;
    /**
     * 对应实体field
     */
    private String column;
    /**
     * 字段输入限制
     */
    private List<DataValidation> validationList;

    public ExcelTplField(String column, String headName) {
        this.headName = headName;
        this.column = column;
    }

    public static String[] getTplHeads(ExcelTplField[] tplHeadArray) {
        String[] tplHeads = new String[tplHeadArray.length];
        for (int i = 0; i < tplHeadArray.length; i++) {
            tplHeads[i] = tplHeadArray[i].getHeadName();
        }
        return tplHeads;
    }

    public String getHeadName() {
        return headName;
    }

    public void setHeadName(String headName) {
        this.headName = headName;
    }

    public String getColumn() {
        return column;
    }

    public void setColumn(String column) {
        this.column = column;
    }

    /**
     * 增加字段限制
     *
     * @param validation
     */
    public void putDataValidation(DataValidation validation) {
        if (null == validation) {
            return;
        }
        if (null == validationList) {
            validationList = new ArrayList<>();
        }
        validationList.add(validation);
    }

    public List<DataValidation> getValidationList() {
        return validationList;
    }

    public void setValidationList(List<DataValidation> validationList) {
        this.validationList = validationList;
    }
}
